home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earcd / utils / vinced / include / dynamics.h < prev    next >
C/C++ Source or Header  |  1997-07-29  |  9KB  |  255 lines

  1. #ifndef VNC_DYNAMICS_H
  2. #define VNC_PYNAMICS_H
  3. /*********************************************************
  4.  ** ViNCEd                                              **
  5.  ** a DOS - window handler                              **
  6.  **                                                     **
  7.  ** © 1991-97 THOR-Software inc.                        **
  8.  ** Version 3.50                                        **
  9.  **                                                     **
  10.  ** program version 1.23 05/03/91       THOR            **
  11.  ** update  version 1.25 06/19/91       THOR            **
  12.  ** header file 06/19/91                THOR            **
  13.  ** updated to 3.30      03/31/97       THOR            **
  14.  ** updated to 3.40      05/08/97       THOR            **
  15.  ** updated to 3.50      07/28/97       THOR            **
  16.  **                                                     **
  17.  ** ViNCEd dynamical memory management                  **
  18.  **-----------------------------------------------------**
  19.  **                                                     **
  20.  ** all use at your own risk,etc.,etc.                  **
  21.  **                                                     **
  22.  ** Everything declared as "reserved" or                **
  23.  ** "not used" is NOT free for your use,                **
  24.  ** it will propably used in a later release.           **
  25.  ** All FREE entries are free for public                **
  26.  ** use and are, if not otherwise noticed,              **
  27.  ** initialized as ZERO                                 **
  28.  *********************************************************/
  29.  
  30. #ifndef EXEC_TYPES_H
  31. #include <exec/types.h>
  32. #endif
  33.  
  34. /* This file is about the dynamical memory nodes.
  35.    Unlike all exec memory, these chunks of memory MIGHT GET MOVED THRU
  36.    SPACE if more room is needed!
  37.  
  38.    SPECIAL CARE MUST BE TAKEN TO HOLD POINTERS ON THESE, SINCE THE
  39.    POINTERS GET INVALID WHEN THESE STRUCTURES ARE TRAVELING!
  40.  
  41.    IF YOU NEED A POINTER TO THEM, STORE IT EITHER IN THE ViNCUserNode
  42.    (see vnc/window.h), OR IN A LINKED LIST. THESE POINTERS GET "BEND"
  43.    AUTOMATICALLY IF THE NODES MOVE AROUND.
  44.  
  45.    IF YOU REMOVE A DYNAMICAL NODE FROM A LIST, MAKE SHURE THAT YOU
  46.    SET THE LINK POINTERS TO ZERO!
  47.  
  48.    BE WARNED! HANDLING WITH THEM IS TRICKY!
  49. */
  50.  
  51. /* An occupied piece of memory, doubly linked for easy freeing and
  52.    garbage collection */
  53.  
  54. struct DynNode {
  55.         struct DynNode                  *dynnd_succ;
  56.         struct DynNode                  *dynnd_pred;    /* linked in
  57.                                                            UsedList */
  58.         UWORD                            dynnd_size;    /* size, including
  59.                                                            structure */
  60. };
  61.  
  62.  
  63. /* Note that the size is needed in case this one must move thru memory,
  64.    for copying it to the destination. The MemBlock ptr is used for fast
  65.    freeing of the structure */
  66.  
  67.  
  68. /* A part of a line on the screen or in the history. */
  69. struct LineBody {
  70.         struct LineBody                 *vln_succln;
  71.         struct LineBody                 *vln_predln;    /* linked list */
  72.         UBYTE                            vln_Status;    /* see below */
  73.         UBYTE                            vln_RasterMask;/* used bitplanes
  74.                                                            for this line
  75.                                                            for quick
  76.                                                            scrolling */
  77.         UBYTE                            vln_PackedPenPair;
  78.                                                         /* A and BPen of
  79.                                                            the first word */
  80.         UBYTE                            vln_PackedType;
  81.                                                         /* Drawmode &
  82.                                                            algostyle */
  83. };
  84.  
  85. /* This is how a line is allocated from memory, and how it's hold */
  86.  
  87. struct DynLine {
  88.         struct DynNode          vline_header;
  89.         struct LineBody         vline_body;
  90. };
  91.  
  92. /* The allocation is done by AllocLine(), FreeLine(). The size given
  93.    to AllocLine is the number of ADDITIONAL BYTES you need, except
  94.    this structure.
  95. */
  96.  
  97. /* How to get the pointer to the first word of a line, i.e. its contents: */
  98.  
  99. #define VLINE_FIRSTWORD(lin)    ((struct ViWord *)((lin)+1));
  100.  
  101. /* REMEMBER THAT LINES LIKE ALL DYNAMICAL NODE STUFF WILL MOVE THRU
  102.    MEMORY. THERE ISN'T A SINGLE BIT IN THE SYSTEM TO PREVENT THEM
  103.    FROM DOING SO! */
  104.  
  105. /* How the pen pairs are packed:
  106.         The upper nibble of the PackedPenPair is the BPen
  107.         (colors 0..15 in bits 7..4)
  108.         The lower nibble is the APen.
  109.         This is the reason why ViNCEd is limited to sixteen
  110.         colors */
  111.  
  112. #define PP_PENMASK      0x0F;
  113. #define PP_BPENSHIFT    4;
  114.  
  115. /* Shift left by BPENSHIFT to get the BPEN, then and with mask */
  116.  
  117. /* How the AlgoStyle is packed: */
  118.  
  119. /* keeps the draw mode for gfx */
  120. #define PA_DRAWMASK     0x06
  121.  
  122. /* must be and-ed to turn on JAM2 */
  123. #define PA_DRAWORF      0x01
  124.  
  125. /* shift by this number to get the algostyle */
  126. #define PA_SOFTSHIFT    3
  127.  
  128. /* use this mask to get the algostyle */
  129. #define PA_SOFTMASK     0x07
  130.  
  131. /* the following bits have a special meaning */
  132.  
  133. /* set if part of the marked block */
  134. #define PA_INBLOCK_BIT          6
  135. #define PA_INBLOCK_MASK         (1L<<6)
  136.  
  137. /* set if not user input, but printed by DOS (ignore on input) */
  138. #define PA_PRINT_BIT            7
  139. #define PA_PRINT_MASK           (1L<<7)
  140.  
  141. /* vln_status bits */
  142.  
  143. /* this was the line the DOS put the cursor in */
  144. #define VLN_DOSLINE_BIT         1
  145. #define VLN_DOSLINE_MASK        (1L<<1)
  146.  
  147. /* this is set if the line end is marked to be in the block as well */
  148. #define VLN_CRADDED_BIT         2
  149. #define VLN_CRADDED_MASK        (1L<<2)
  150.  
  151. /* the next three are reserved for foldings. Not yet used, however */
  152. #define VLN_INFOLD_BIT          3
  153. #define VLN_INFOLD_MASK         (1L<<3)
  154. #define VLN_STARTFOLD_BIT       4
  155. #define VLN_STARTFOLD_MASK      (1L<<4)
  156. #define VLN_ENDFOLD_BIT         5
  157. #define VLN_ENDFOLD_MASK        (1L<<5)
  158.  
  159. /* this one is set if the line is part of a marked block */
  160. #define VLN_INBLOCK_BIT         6
  161. #define VLN_INBLOCK_MASK        (1L<<6)
  162.  
  163. /* set if the complete line contains no user input */
  164. #define VLN_PRINT_BIT           7
  165. #define VLN_PRINT_MASK          (1L<<7)
  166.  
  167.  
  168. /* The snip documentation is removed from this file. The snip
  169.    structures have changed and are now PRIVATE. */
  170.  
  171.  
  172. /* The next two represent a line in the output buffer of ViNCEd.
  173.    Again, AllocLine() and FreeLine() are used to allocate/free them,
  174.    and again a dynamical node is used for allocation.
  175.    The size is again the same as the LineBody!
  176.    BEWARE: THIS WILL MOVE THRU MEMORY IF NEEDED ! */
  177.  
  178. struct OutNodeBody {
  179.         struct OutNodeBody      *von_succ;
  180.         struct OutNodeBody      *von_pred;      /* again, doubly
  181.                                                    linked list */
  182.         UWORD                    von_TextSize;  /* readable characters
  183.                                                    in here */
  184.         UWORD                    von_Offset;    /* offset from beginning
  185.                                                    of the output buffer */
  186. };
  187.  
  188. /* And this is how it looks like in memory */
  189.  
  190. struct DynOutNode {
  191.         struct DynNode          doutn_header;
  192.         struct OutNodeBody      doutn_body;
  193. };
  194.  
  195.  
  196. /* Use this macro to get the first character in here */
  197. #define DOUTN_FIRSTCHAR(on)     ((char *)((on)+1))
  198.  
  199.  
  200. /* This is the word structure I mentioned above.
  201.    Unlike what you might think, it does not hold a "word" in the common
  202.    sense, but a sequence of characters of the same pens and draw
  203.    modes. Big areas of blank spaces are not hold in the word structures
  204.    as well, since they only eat up memory. They are removed from the
  205.    lines, and the word position is adjusted.
  206.    This is the ViNCEd way to compress its contents. */
  207.  
  208. struct ViWord {
  209.         UBYTE           vwd_size;       /* size of word in characters.
  210.                                            zero if this is the last word
  211.                                            in a line */
  212.         UBYTE           vwd_PackedPenPair;      /* PP, packed like in
  213.                                                    lines */
  214.         UBYTE           vwd_PackedType; /* DrawMode and style, again
  215.                                            packed like above */
  216.         UBYTE           vwd_XPos;       /* absolute position in the line */
  217. };
  218.  
  219. /*How to get the contents of a ViWord: */
  220.  
  221. #define WORD_BODY(wd)   ((char *)((wd)+1))
  222.  
  223. /*And how to get the next word */
  224.  
  225. #define NEXT_WORD(wd)   ((struct ViWord *)(WORD_BODY((wd))+(wd->vwd_size)))
  226.  
  227.  
  228. /* The maximum size of a line */
  229. #define VLINE_MAXLENGTH         243
  230. #define VLINE_ML                (VLINE+MAXLENGTH+1)
  231.  
  232. /* Additional room */
  233. #define VCHAR_SIZE              258
  234.  
  235. /* The next one is not dynamic, and holds an uncompressed line */
  236. struct VCharLine {
  237.         char            vch_char[VCHAR_SIZE];
  238.         struct {
  239.                 UBYTE vch_PackedPenPair;
  240.                 UBYTE vch_PackedType;
  241.         }               vch_Types[VCHAR_SIZE];
  242. };
  243.  
  244.  
  245. /* VCharLines are easier to handle, DynLines take up less memory and are
  246.    used everywhere else except for the current editor line (the line under
  247.    the cursor).
  248.    Use LineToLinear() and LinearToAlloc()/LinearToLine() to convert between
  249.    the types. */
  250.  
  251. #endif
  252.  
  253.  
  254.  
  255.